import { Entity } from "./Entity";
import { SceneType } from "./SceneType";

export class Scene extends Entity {

    public Zone: number;
    public SceneType: number;
    public Name: string;

    constructor(id: number, instanceId: number, zone: number, sceneType: SceneType, name: string, parent: Entity) {
        super();
        this.Id = id;
        this.InstanceId = instanceId; 0
        this.Zone = zone;
        this.SceneType = sceneType;
        this.Name = name;
        this.IsCreated = true;
        this.Parent = parent;
        this.Domain = this;
        this.IsRegister = true;

        console.info(`scene create: ${this.SceneType} ${this.Name} ${this.Id} ${this.InstanceId} ${this.Zone}`);
    }

    Dispose() {
        super.Dispose();

        console.info(`scene dispose: ${this.SceneType} ${this.Name} ${this.Id} ${this.InstanceId} ${this.Zone}`);
    }

    public get Domain(): Entity {
        return this.domain;
    }

    private set Domain(value: Entity) {
        this.domain = value;
    }

    public set Parent(value: Entity) {
        if (value == null) {
            return;
        }
        this.parent = value;
        this.parent.Children.Add(this.Id, this);
    }

}